/**
 * 
 */
package studyspots.feup;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * Serve para modificar o aspecto da title bar.
 *
 */
public class CustomWindow extends Activity {
	SharedPreferences preferences; // Onde vamos guardar um apontador para as prefernecias
	public Profile myProfile;	// Onde guardamos o profile do user sempre que vemos buscar a my app
    protected TextView title;
    protected ImageView icon;
    protected ImageView homeIcon;
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
 
        setContentView(R.layout.main);
 
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
 
        title = (TextView) findViewById(R.id.title);
        homeIcon  = (ImageView) findViewById(R.id.icon);
        //homeIcon = (ImageView) findViewById(R.id.header);
        
	    this.homeIcon.setClickable(true);
	    this.homeIcon.setOnClickListener(homeIconListener);
    }
    
    
	/**
	 * Atalho para ir rapidamente para o home
	 * 
	 */
	private View.OnClickListener homeIconListener = new View.OnClickListener() {
		public void onClick(View v) {

//			String username = preferences.getString("username", "n/a");
//			String password = preferences.getString("password", "n/a");
//			Toast.makeText(
//					CustomWindow.this,
//					"Input: " + username + " and password: "
//							+ password, Toast.LENGTH_LONG).show();
			
			Intent newIntent = new Intent(v.getContext().getApplicationContext(), MainActivity.class);
			newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);  
			startActivityForResult(newIntent, 0);
			finish();

		}

	};
}
